package com.bom.boot.easy.entity;

import com.bom.boot.easy.core.comment.Comment;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;

@Data
@Entity(name = "ops_option_out")
@Comment("操作出参表")
public class OptionOutEntity {
    @EmbeddedId
    @JoinColumn(foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private OptionOutId id;

    @Comment("出参标题")
    private String title;

    @Comment("别名")
    private String alias;

    @Comment("格式化")
    private String format;

    @EqualsAndHashCode(exclude = "option")
    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    @Embeddable
    public static class OptionOutId implements Serializable {
        @Comment("操作名称")
        @ManyToOne
        @JoinColumns(value = {@JoinColumn(name = "page_name"), @JoinColumn(name = "option_name")}, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
        private OptionEntity option;

        @Comment("出参名称")
        private String name;
    }
}
